/**
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file -- DO NOT EDIT!

#include "bytecode_optimizer/reg_encoder.h"

void CheckWidthAbcKitIntrinsic(ark::bytecodeopt::RegEncoder *re, ark::compiler::Inst *inst)
{
    ASSERT(inst->IsIntrinsic());
    switch(inst->CastToIntrinsic()->GetIntrinsicId()) {
#include "dyn_intrinsics_cases.inc"
% Compiler::intrinsics.select {|intrinsic| intrinsic.space == "abckit" }.each do |intrinsic|
    case ark::compiler::RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>:
%   if (intrinsic.method_name.include? "range")
            re->Check4Width(inst);
            return;
%   end
%   inst = nil
%   Panda::instructions.each do |asm_ins|
%     if (asm_ins.mnemonic == intrinsic.method_name)
%       inst = asm_ins
%     end
%   end
%  reg = inst.operands.select(&:reg?).first
%  if reg
            re->Check<%= reg.width %>Width(inst);
            return;
%  else
            return;
%  end
% end
        default:
            return;
    }
}

bool IsDstRegNeedRenumbering(ark::compiler::Inst *inst) {
    if (!inst->IsIntrinsic()) {
        return false;
    }
    if (inst->CastToIntrinsic()->GetIntrinsicId() == ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_LOAD_OBJECT ||
        inst->CastToIntrinsic()->GetIntrinsicId() == ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_LOAD_OBJECT_WIDE ||
        inst->CastToIntrinsic()->GetIntrinsicId() == ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_LOAD_OBJECT_OBJECT ||
        inst->CastToIntrinsic()->GetIntrinsicId() == ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_NEW_ARRAY) {
        return true;
    }
    return false;
}
